package com.ksy.common.dialog;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.ksy.common.R;


/**
 * Created by Ksy.
 */

public class NoticeDialog extends CenterDialog {

    private TextView dialog_tip;
    private View dialog_cancel;
    private View dialog_enter;
    private String tipMsg;
    private ClickListener onClickListener;

    public NoticeDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_layout_dialog_notice);
        dialog_tip = findViewById(R.id.dialog_tip);
        dialog_tip.setText(tipMsg);
        dialog_cancel = findViewById(R.id.dialog_cancel);
        dialog_enter = findViewById(R.id.dialog_enter);
        dialog_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        dialog_enter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClickListener != null) {
                    onClickListener.enter(NoticeDialog.this);
                }
            }
        });
    }

    public NoticeDialog setMsg(String tipMsg) {
        this.tipMsg = tipMsg;
        if (dialog_tip != null) {
            dialog_tip.setText(tipMsg);
        }
        return this;
    }

    public NoticeDialog setOnClickListener(ClickListener onClickListener) {
        this.onClickListener = onClickListener;
        return this;
    }

    public interface ClickListener {
        void enter(BaseDialog dialog);
    }
}
